<!doctype html >
<html lang="{{ config('app.locale') }}">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, max-scale=1, min-scale=1,user-scalable=no">
    <meta name="_token" content="{{ csrf_token() }}"/>


    <!--引入微信js-SDK-->
    {{--<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>--}}
    {{--<script type="text/javascript" src=" {{env('CDN_RESOURCE')}}/js/mobile/feedback/wx_config.js"></script>--}}


    <link href="{{env('CDN_RESOURCE')}}/css/mobile/feedback/mobile.css?v={{config('app.version')}}" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="https://res.wx.qq.com/open/libs/weuijs/1.1.2/weui.min.js"></script>
    <link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/1.1.2/weui.min.css">

    {{--<script src="http://qzonestyle.gtimg.cn/open/qcloud/video/h5/h5connect.js"></script>--}}


    <script type="text/javascript" src="https://static-app.97kid.com/wx/js/zepto.min.js"></script>
    <script type="text/javascript" src="{{env('CDN_RESOURCE')}}/js/mobile/Zepto_fx_methods.js"></script>
    <script type="text/javascript" src="{{env('CDN_RESOURCE')}}/js/mobile/login.js"></script>


    <title>久趣英语</title>

</head>
<body>
<div class="review-container">
    <div class="lesson">
        <img class="icon" src="https://static-app.97kid.com/site-student/public/img/share.png" />
        <div class="info">
            <div class="name"></div>
            <div class="teacher"></div>
            <div class="time"></div>
            <div class="triangle"></div>
        </div>
    </div>
    <div class="review">
        <div class="title">亲爱的家长：</div>
        <div class="content"></div>
        <div class="show">查看我的评价</div>
    </div>
</div>
<div class="feedback">
    <div class="title">
        <h3>我的评价</h3>
        <div class="close"></div>
    </div>
    <div class="rating">
        <div class="system">
            <div class="label">系统评分</div>
            <div class="stars">
                <div class="dis-star-icon"></div>
                <div class="dis-star-icon"></div>
                <div class="dis-star-icon"></div>
                <div class="dis-star-icon"></div>
                <div class="dis-star-icon"></div>
            </div>
        </div>
        <div class="teacher">
            <div class="label">老师评分</div>
            <div class="stars">
                <div class="dis-star-icon"></div>
                <div class="dis-star-icon"></div>
                <div class="dis-star-icon"></div>
                <div class="dis-star-icon"></div>
                <div class="dis-star-icon"></div>
            </div>
        </div>
    </div>
    <div class="content"></div>
</div>
<div class="feedback-mask"></div>
</body>
</html>


<script type="text/javascript">

    (function ($) {
        $(function () {
            $('.review .show').on('click', function () {
              $('.feedback-mask').fadeIn();
              $('.feedback').addClass('feedback_toggle');
            });
            $('.feedback .close').on('click', function () {
              $('.feedback-mask').fadeOut();
              $('.feedback').removeClass('feedback_toggle');
            });

            var account = new Account();
            account.ajax({
              type: 'GET',
              path: '/s/appointments/{{$appointmentId}}',
              success: renderLesson,
              error: function (err) {
                //unFeedback = false;
                $.toastAlert(err.message);
              }
            });

            account.ajax({
              auth: 'false',
              type: 'GET',
              path: '/s/appointments/{{$appointmentId}}/feedback',
              success: renderFeedback,
              error: function (err) {
                //unFeedback = false;
                $.toastAlert(err.message, 2);
              }
            });


            function renderLesson(appointment) {
              var course = appointment.course || {};
              var lesson = appointment.lesson || {};
              var lessonName = '';
              if (course.level) {
                if (course.seriesId == 1) {
                  lessonName += 'L' + course.level;
                } else if(course.seriesId == 3) {
                  lessonName += 'PL' + course.level;
                }
              }
              lessonName += ' Lesson ' + lesson.name;
              $('.lesson .name').text(lessonName);
//              lesson.logoUri && $('.lesson .icon').attr('src', 'https://gstatic.97kid.com' + lesson.logoUri);

              if (appointment.beginAt) {
                var beginAt = new Date(appointment.beginAt * 1000);
                var year = beginAt.getFullYear();
                var month = beginAt.getMonth() + 1;
                var date = beginAt.getDate();
                var hour = beginAt.getHours() < 10 ? '0' + beginAt.getHours() : beginAt.getHours();
                var minute = beginAt.getMinutes() < 10 ? '0' + beginAt.getMinutes() : beginAt.getMinutes();
                $('.lesson .time').text(year + '年' + month + '月' + date + '日 ' + hour + ':' + minute);
              }

              if(appointment.teacherId > 0) {
                account.ajax({
                  type: 'GET',
                  path: '/s/teachers/' + appointment.teacherId,
                  success: function (data) {
                    $('.lesson .teacher').text(data.nickname);
                  }
                });

              }
            }

            function renderFeedback(feedback) {
              $('.review .content').text(feedback.result);
              $('.feedback .content').text(feedback.review);
              $('.system .dis-star-icon').each(function (index, node) {
                console.log(index);
                if (index < parseInt(feedback.rating, 10)) {
                  $(node).addClass('star-icon');
                }
              });
              $('.teacher .dis-star-icon').each(function (index, node) {
                if (index < parseInt(feedback.teacherRating, 10)) {
                  $(node).addClass('star-icon');
                }
              });
            }
        });

    })(window.Zepto);

</script>
